How To Display UTF8 in your Putty Bash Shell

I was having a few reading problems on a server I've recently got my hands on: the locale is set to something like French UTF8, but Putty was displaying annoying é and stuff instead of accented characters.

I was expecting the solution to be something linuxish like read boring man pages till I finally decide it's not worth the hassle and live with it, but it was so simple that I'm still amazed. Just add the following lines (in your ~/.bash_profile for instance:

  1. echo -ne '\e%G\e[?47h\e%G\e[?47l'

No idea why it works, if it's for bash or any shell, but well, it just works. Cool ! (via)

Edit: As a few readers commented, there's something way easier to do in your PuTTy configuration. Read comments :)

22 comments

  1. Daniel Fort

    Thnx man, that really hepled.

  2. Renny

    Thanks again! Your post did save me so much time!!!

  3. Santiajo

    Did you set in putty UTF-8 char set?

    Configuration -> Window -> Translation -> UTF-8

  4. Ozh

    Santiajo » Oh… My… God. Never saw this setting before… Thanks! :)

  5. Fabio Salles

    Thank u 2!!(Ozh and Santiajo)
    This information has change my life!! &;p

  6. diego

    espectacular….. no entiendo porque sirve….
    Pero funciona perfecto…
    Gracias

  7. redCube

    In PuTTY 0.60 you can change the option "Window > Translation > Received data assumed to be in which character set:" to UTF-8. After this all received data will be interpreted as UTF-8 and displayed correctly.

  8. redCube

    Damn, might help to read other comments first. Sorry for an allready posted solution. ;)

  9. dasz.at – Benutzbare Technologie» Blog Archive » PuTTY: default to UTF-8

    […] are quite a few posts on how setting the "Window > Translation > Received Charset" of PuTTY to […]

  10. Sz.abi

    Hm,

    I have been using PuTTY for years.
    The first time I'd want to use UTF-8, but I experience a weird thing:

    1.) if I set in the Options Translation to "UTF-8", everything gets correctly displayed, but I cannot input any characters beyond U+7F (traditional ASCII, not even Latin-1!!!). (whenever I press a key which has a para-ASCII number assigned, nothing gets sent to the PuTTY terminal. Nothing at all).

    2.) if I use the above described method (echo -ne '\e%G\e[?47h\e%G\e[?47l'), I get the same display and I CAN input any unicode number, which is however incorrectly translated to the terminal.

    So I'm stuck, actually neither 1), nor 2) helps.

    I'd love to hear some tips how to get PuTTY via the Translation-> UTF-8 working…

  11. sempernoctis

    As a point of clarification, the echo command configures the shell on the remote system (I'm not sure exactly what it does, but it is causing it to echo escape sequences through the console, which are commonly used for controlling various ways the console behaves). The PuTTY setting configures how your client handles data coming from the server. Presumably both your client and the server you are accessing would have to be configured to talk UTF-8 (or some other character set that supports wide characters, as long as they are configured to use the same one). My Debian Etch install with bash appears to handle UTF-8 by default; all I had to do was change the PuTTY configuration to deal with it properly. I would expect that older linux versions, some other distributions, or other shells might have different default configurations.

  12. tom3k

    kick ass dood!

    thanks a million!

  13. Denis

    Thank you very much! This is simple, and it works.

    Denis

  14. rodgiarrr

    thanks to the person who said:

    "The PuTTY setting configures how your client handles data coming from the server"

    that appears to be true:

    i looked and on the left side of the putty window, theres lots of menus that i had never looked into, one of them allows you to chose the charset putty uses.. it was ISO something just changed it to UTF8 (and reconnected) and now all the accents show up fine. no need to edit dirty bash files!

  15. Whitesands

    Thanks man! This works!

  16. Ols

    Thanks for this!

  17. Ryan

    Not sure how I overlooked the option of setting PuTTY to use UTF-8. Thanks for the tip.

  18. David

    %G sends xterm terminal (putty) code to select utf-8 character set

    [?47h select (dsiplay) xterm aternate screen buffer (it apparaently, amazingly has two screen buffers…)

    %G select utf-8 character set again on this screen

    [?47l back to normal screen buffer

    That is my understanding of it…

  19. David

    retrying shwoing 'esc' within brakcets….
    <esc>%G sends xterm terminal (putty) code to select utf-8 character set

    <esc>[?47h select (dsiplay) xterm aternate screen buffer (it apparaently, amazingly has two screen buffers…)

    <esc>%G select utf-8 character set again on this screen

    <esc>[?47l back to normal screen buffer

  20. LiveChat.Zone

    thank you so much! This works great!

  21. Viacheslav

    Some Unicode characters (arrows, for example) looks like squares in Courier New font. ? – this symbol, for example. It shows fine in web browser with the same Courier New font.

  22. Viacheslav

    Oh, crap, it was "North West Arrow" symbol.

Comments are closed.